# 构建阶段
FROM node:16-alpine AS build

# 设置工作目录
WORKDIR /app

# 安装依赖
COPY package.json package-lock.json* ./
RUN npm config set registry https://registry.npmmirror.com/
RUN npm ci

# 复制源代码并构建
COPY . .
RUN npm run build

# 生产阶段
FROM nginx:alpine

# 复制构建产物到 Nginx 目录
COPY --from=build /app/dist /usr/share/nginx/html

# 复制自定义的 Nginx 配置文件
COPY nginx.conf /etc/nginx/conf.d/default.conf

# 暴露端口
EXPOSE 80

# 启动 Nginx
CMD ["nginx", "-g", "daemon off;"] 